package com.icehand.proxy.demo;

import com.icehand.proxy.demo.cglib.CglibDynamicProxy;
import com.icehand.proxy.demo.impl.Behavior;
import com.icehand.proxy.demo.impl.Bird;
import com.icehand.proxy.demo.impl.Duck;
import com.icehand.proxy.demo.jdk.JdkDynamicProxy;
import com.icehand.proxy.demo.stat.StaticProxy;

/**
 * @author icehand
 */
public class MainClass {
    public static void main(String[] args) {
        //静态代理
        Behavior duck = new Duck();
        StaticProxy staticProxy = new StaticProxy(duck);
        staticProxy.say();

        System.out.println("-------------------");

        //JDK动态代理
        JdkDynamicProxy jdkDynamicProxy = new JdkDynamicProxy();
        Behavior behavior = (Behavior)jdkDynamicProxy.bind(new Bird());
        behavior.say();

        System.out.println("-------------------");

        //Cglib动态代理
        CglibDynamicProxy proxy = new CglibDynamicProxy();
        Duck duck1 = (Duck) proxy.getInstance(new Duck());
        duck1.say();
    }
}
